<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>
<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

</head>
<body style="font-family: '微软雅黑'">
<div id="tb" style="padding:5px;height:auto">
        <div>
        	<form id="searchFrom" action="">
       	        <input type="text" name="userName" class="easyui-validatebox" data-options="width:150,prompt: '理财师姓名'"/>
       	        <input type="text" name="uid" class="easyui-validatebox" data-options="width:150,prompt: '理财师编码'"/>
       	        <input type="text" name="telephone" class="easyui-validatebox" data-options="width:150,prompt: '手机号'"/>
       	        <input type="text" name="beginDate" class="easyui-my97" datefmt="yyyy-MM-dd" onfocus="WdatePicker({minDate:'2015-08-01',maxDate:'%y-%M-%d'})" data-options="width:150,prompt: '开始日期'"/> - 
				<input type="text" name="endDate" class="easyui-my97" datefmt="yyyy-MM-dd" onfocus="WdatePicker({minDate:'2015-08-01',maxDate:'%y-%M-%d'})" data-options="width:150,prompt: '结束日期'"/>
				
		        <span class="toolbar-item dialog-tool-separator"></span>
		        <a href="javascript(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="cx()">查询</a>
<!-- 		        <a href="javascript(0)" class="easyui-linkbutton" iconCls="icon-standard-page-go" plain="true" onclick="addIntegral()">补录积分</a> 
					<a href="javascript(0)" class="easyui-linkbutton" iconCls="icon-standard-page-go" plain="true" onclick="useIntegral()">积分兑换</a>-->
			</form>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-standard-page-go" plain="true" onclick="exportData()">数据导出</a>
        </div> 
        
</div>
<table id="dg"></table> 
<div id="dlg"></div> 
<div id="dlg2"></div>  
<script type="text/javascript">
var dg;
$(function(){   
	dg=$('#dg').datagrid({    
	method: "get",
    url:'${ctx}/userIntegral/json',
    fit : true,
	fitColumns : true,
	border : false,
	striped:true,
	idField : 'uid',
	pagination:true,
	rownumbers:true,
	pageNumber:1,
	pageSize : 20,
	pageList : [ 10, 20, 30, 40, 50 ],
	singleSelect:true,
    columns:[[    
		{field:'userName',title:'理财师姓名',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'uid',title:'理财师编码',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'telephone',title:'手机号',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'userDept',title:'营业部',sortable:false,align:'center',width:68,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'incomeScore',title:'收入积分',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'outputScore',title:'支出积分',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'restScore',title:'剩余积分',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return value;
		}},
		{field:'cz',title:'操作',sortable:false,align:'center',width:30,formatter:function(value,rowData,rowIndex){
			return '<a href="javascript:void(0)" onclick="queryUserIntegral('+rowData.uid+')">查看明细</a>';
		}}
    ]],
    enableHeaderClickMenu: false,
    enableHeaderContextMenu: false,
    enableRowContextMenu: false,
    toolbar:'#tb'
	});
});

//创建查询对象并查询
function cx(){
	var obj=$("#searchFrom").serializeObject();
	obj.userName = encodeURIComponent(obj.userName);
	dg.datagrid('reload',obj); 
}

//补录积分
function addIntegral(){
	parent.$.messager.confirm('提示', '您确定要补积分？', function(data){
		if (data){
			$.ajax({
				type:'get',
				url:"${ctx}/userIntegral/addIntegralBetach/",
				success: function(data){
					if(successTip(data,dg))
			    		dg.treegrid('reload');
				}
			});
			//dg.datagrid('reload'); //grid移除一行,不需要再刷新
		} 
	});
}

function queryUserIntegral(uid) 
{
	d = $("#dlg").dialog({
		title : '积分明细',
		width : 680,
		height : 394,
		href : '${ctx}/userIntegral/detailList/' + uid,
		maximizable : true,
		modal : true,
		buttons : [{
			text : '取消',
			handler : function() {
				d.panel('close');
			}
		} ]
	});
}

//导出数据
function exportData(){
	var obj=$("#searchFrom").serializeObject();
	var userName = obj.userName;
	var uid = obj.uid;
	var telephone = obj.telephone;
	var beginDate = obj.beginDate;
	var endDate = obj.endDate;
	
	window.location.href="${ctx}/userIntegral/export?userName="+encodeURI(encodeURI(userName))+"&uid="+uid+"&telephone="+telephone+"&beginDate="+beginDate+"&endDate="+endDate;
}

//积分兑换
function useIntegral(){
	parent.$.messager.confirm('提示', '您确定要兑换积分么？', function(data){
		if (data){
			$.ajax({
				type:'get',
				url:"${ctx}/userIntegral/useIntegralBetach?endDate=2015-09-06",
				success: function(data){
					if(successTip(data,dg))
			    		dg.treegrid('reload');
				}
			});
		} 
	});
}

</script>
</body>
</html>